Skip to main content

Full text of "Programming"

See other formats

InterActive 2 


Make Projects 

build, hack, tweak, share, discover^ 

InterActive 2 

Written By: Steven Robert Cypherd 


This is an explanation of the code for the flow control I came up with it to get my Basic 
Stamp 2(BS2) talking to my Basic Stamp 1(BS1). I am showing the main loops only. For the 
code files look at and Files or a zip file. 

In my code I use a lot of Bit flags. Most processors allow access to the Bits of a Byte or 
Word to use like regular variables. Basic Stamp 1 and most Picaxe processors have defined 
variable names for the Bits of first few bytes of memory. Usually it is BitO - Bit7 or BitO - 
B15 or BitO - Bit31 to define a variable. In both of these processors the variable Bits can 
also be in another variable. Like my lights Byte BO the Bits are the variables BitO - 7 that are 
Iit1 - 1 its the individual lights. This makes testing of a light easy. "If Iit1 = 1 then litOn" is 

The Basic Stamp 2 and processors like it use defined subscripting to access the Bits, 
Nibbles and Bytes of a variable. My individual lights are the variables "lights. BitO - Bit7". In 
testing a variable Bit is "if Ights.BitO = 1 then litOn". Setting is "litTmp = lights. BitO". Usually 
the subscripts can not be a variable. Look at the program files in the EasyLights article. 
Read your manual. 

I fixed as much as I could. The BS1 doesn't do serial out very well. It is stable and runs like 
any simple button on a system like this. The BS1 doesn't do Bits very well either. 

My flow control is the only way I got these systems to communicate. 

I uploaded full code pictures. 

© Make Projects Page 1 of 3 

InterActive 2 

Step 1 — InterActive 2 

Interactive 2 

All KxpUicintion Of 
my code for my x 
Flow Control. J 

— ■"*■ — 1 -'^t"|*" ISb ■ WUuTiK 

n ru> iiu^JtM. nth ■iu-k*f*- 

nhl)»] Win Via * ■■ '■ 

nBnial D 41 Una 

I Km. VVUww >-. T* WbkCv 
I Tx niuir- > R* HSmrk 
I G Ftlarfc G fiwrrn 

h •■ItaitSvi' 

mi V* faa 

"■■■■W^f 1 - 't*-L»^™ 

Mf 1 I*— nil— wu 

■ pt-e tUMt- * OUIl 

]*?.*° _ 1 ■ ^, 

I ^i\-f :,'■*-,,.. 


H*A-fertrn DKN^jl. 1 **fckrjlC* 

• Get them talking. Fixed it. 

• Here the the last working version with the BS1 . Two bytes in OK, but not one good byte 

• Here are the code pictures. 

Step 2 

...... -ij... .,.< .. ■ ., am 

#B?-frhftt>lp-»' 1 


ik'- • HMIB4 


..,-. :■ 


— - 
■-■ me ■ 

kml .i> 

BOD ■*« 

IpAM - IW ill 


MAM ■ -•■■., 


■iM* ■■ i"HT|t'f*(l«* 

■ *lai- -DiVfi ma pi inan 


• Last page of BS2 12 

• BS1 12 code. 

© Make Projects 

Page 2 of 3 

InterActive 2 

MM- 14 KTlw»k«!-M .IJUV.j 

vt p*+ 

■u. mi 

ET* ««|S, 


ii m r n 

PiKldW "flWfcrtH 1 '' 

• First working version BS2 11 

• First working version BS1 11 

«jn2: Look tot message from the rrtaster 
IF sJ3et = 01HEN|pl'SetUp 
IF pRx = 1 THEr-J Jpl 'Checi lot message 
SERIN plnlix T2100, mCmd, tmpl 

IF mCmd <> BS1PP THEN jpl 'Check for correct address 
lights = tmpl 
GOSUB aoLigfrR 
jpl r'Clear buttons 

IF pBlnl - 1 THEN jp2 

IF pBm2 - 1 THEN jp2 

bDowh = 

btnl -0 

jp2;'Set up slarwe 

IFslSel = 1 ThiENjp3 

tmpl = tmpl -t- 1 

IF tmpl < 10THENJP3 

5Eet = 1 
SOTO writ 

>SubHqut(ng5 ******************************** 
delights; 'Rom EdsyUghts article 
FOB tmpl - IO 7 

litlmp = tmpl 


IF lltTmp = 1 THEN dolltOn 'A ample test 

pDdta = licit : GOTO doLJCk 


pDcta - litOn 


pCbck - litOh 

pCLOCfc - ItOlt 


'Each Lit Is 1 for on and D for otf 
checlrllghts: An Array (or anything 
6EANCHIItTmp,(CUJtl.ctUt2,ckLlt3 1 ckLlt4,ckLrl5,ckUt6.CUJt7.ckLit8] 

CHIN: litrmp - Iltl ; GOTOdcneCtiecklt 

cult2: litrmp - Ilt2 : GOTOdoneChecklt 

cuit3; litrmp - IBS ; GOTOdoneCnecklt 

cuitd: BTmp = lltj ; GOTOdoneChecklt 

ekUt5: Itlmp = Ilt5 : GOTOdoneChecklt 

clUt4: KTrnp - lit* : GOTOdaneCnecklt 

cuit7: Itrmp = lit? : GOTOdoneChecklt 

ctlitS: litrmp - lite 


• Last page BS1 11 

Get them Talking. 

This document was last generated on 2012-1 1-02 04:41 :1 1 AM. 

© Make Projects 

Page 3 of 3